﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace ElfTyping.States.GameState.Entities
{
    public class RogueEnemy : Enemy
    {
        private float timeLeftWaitingToAttack = 0.5f;
        private float timeBeforeActive = 1f;

        public RogueEnemy(GameScript script, Vector2 centerPosition, EnemyDifficulty difficulty)
            : base(script, centerPosition, difficulty)
        {
            switch (difficulty)
            {
                case EnemyDifficulty.Easy:
                    LoadAnimations(@"Textures\GameState\Rogue_Green");
                    MaximumHealth = 1;
                    Damage = 2;
                    Experience = 2;
                    BaseSpeed = random.Next(50,70);
                    Word = GetNewWord(4);
                    break;

                case EnemyDifficulty.Medium:
                    LoadAnimations(@"Textures\GameState\Rogue_Purple");
                    MaximumHealth = 1;
                    Damage = 3;
                    Experience = 4;
                    BaseSpeed = random.Next(60, 80);
                    Word = GetNewWord(5);
                    break;

                case EnemyDifficulty.Hard:
                    LoadAnimations(@"Textures\GameState\Rogue_Red");
                    MaximumHealth = 1;
                    Damage = 4;
                    Experience = 8;
                    BaseSpeed = random.Next(70, 90);
                    Word = GetNewWord(6);
                    break;
            }

            AttackingAnimation.SetAnimateBackwards();
        }

        public override void Tick(float dt)
        {
            CurrentAnimation = (IsActive && timeBeforeActive < 0) ? MovingAnimation : AttackingAnimation;

            if (IsActive && timeBeforeActive >= 0)
            {               
                timeBeforeActive -= dt;
            }
            else if (IsActive || timeLeftWaitingToAttack <= 0)
            {
                MoveCenter(CenterPosition.X + MoveSpeed * dt, CenterPosition.Y);
            }
            else
            {
                timeLeftWaitingToAttack -= dt;
            }

            base.Tick(dt);
        }
    }
}
